package beans;
import java.sql.*;
public class dbc {
	private static String driverName="com.mysql.jdbc.Driver";
	private static String userName="root";
	private static String userPwd="ab123";
	private static String dbName="users";
	public static Connection getDBconnection(){
		String url1="jdbc:mysql://127.0.0.1:3306/"+dbName;
	    String url2="?user="+userName+"&password="+userPwd;
	    String url3="&useUnicode=true&characterEncoding=UTF-8";
	    String url=url1+url2+url3;	
	    try{
	    	Class.forName(driverName);
	    	Connection con=DriverManager.getConnection(url);
	    	return con;	    	
	    }catch(Exception e){e.printStackTrace();}
	    return null;
	}
	public static void closeDB(Connection con,PreparedStatement pstm,ResultSet rs){
		try{if(pstm!=null)pstm.close();
	    if(con!=null)con.close();
	    if(rs!=null)rs.close();
	}catch(SQLException e){e.printStackTrace();}
	}
    
    

}
